<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no" />
  <title>返回顶端</title>
  <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="./css/common.css" type="text/css" />
  <link rel="stylesheet" href="./css/backtop.css" type="text/css" />
</head>

<body>
  <div class="box">
    <div class="back">返回顶端</div>
  </div>
  <script src="./js/backtop.js"></script>
  <script>
    let backtop = new BackTop('.back')
  </script>
</body>

</html>
<!--
  1、获得元素的顶端滚动距离
    // goggle的获取方式
    let scrollTop = document.body.scrollTop
    // FireFox IE
    let scrollTop = document.documentElement.scrollTop
  2、设置元素的顶端滚动距离
    document.body.scrollTop = 100
    document.documentElement.scrollTop = 200
  3、监听元素的滚动事件
    el.addEventListener('scroll', function(){}, false)
  4、获得视口宽度和高度
    let html = document.documentElement
    let body = document.body
    let width = html.clientWidth || body.clientWidth
    let height = html.clientHeight || body.clientHeight
 -->